<layout name='Layout/layout_main' />
<tagLib name="html" />
<script type="text/javascript">
	function add() {
		$("#form_data :input :not(:button)").each(function() {
			$(this).val("");
		});
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#form_data select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".sub_left_menu tbody tr.active").removeClass("active");
		$("#opmode").val("add");
	}

	function reset_pwd() {
		if ($("#id").val().length < 1) {
			alert("请选择用户");
			return false;
		}
		winopen("{:U('password')}?id=" + $("#id").val(), 400, 300);
	}

	function select_dept() {
		winopen("{:U('dept/winpop2')}", 600, 400);
	}

	function btn_search() {
		sendForm("form_search", "__SELF__");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__");
			return false;
		}
	}

	function save() {
		$("#pic").val($("#save_name").val().split(";")[0]);
		if (check_form("form_data")) {
			sendForm("form_data", "{:U('save')}", "__URL__");
		}
	}

	function showdata(result) {
		for (var s in result.data) {
			set_val(s, result.data[s]);
		}
		$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
		img_url = "{:C('SAVE_PATH')}" + $("#pic").val();
		$("#emp_pic").attr("src", img_url.split(";")[0]);
		$("#save_name").val("");
		$("#opmode").val("edit");
	}


	$(document).ready(function() {
		$(".input-date").datepicker();

		$(".sub_left_menu tbody tr").click(function() {
			$(".sub_left_menu tbody tr.active").removeClass("active");
			$(this).attr("class", "active");
			sendAjax("{:U('read')}", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})
	});

</script>
<form method="post" action="" id="form_search" name="form_search">
	<div class="title panel panel-default">
		<div class="panel-body">
			<h3 class="col-md-8">用户管理</h3>
			<div class="col-md-4 pull-right">
				<div class="search_box">
					<div class="input-group ">
						<input  class="form-control" type="text"  onkeydown="key_search();" name="keyword" id="keyword"/>
						<div class="input-group-btn">
							<a class="btn btn-default" onclick="btn_search();" > <i class="icon-search" ></i> </a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
<form id="form_data" name="form_data" method='post'>
	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-right">
				<a onclick="reset_pwd()" class="btn btn-default">设置密码</a>
				<a onclick="add()"  class="btn btn-default">新增</a>
				<a onclick="save()"  class="btn btn-default">保存</a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-4 sub_left_menu ">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>员工编号</th>
						<th>姓名</th>
						<th>状态</th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="data">
						<tr id="{$data.id}">
							<td>{$data.emp_no}</td>
							<td>{$data.emp_name}</td>
							<td>{$data.is_del|status}</td>
						</tr>
					</volist>
				</tbody>
			</table>
		</div>
		<div class="col-md-8">
			<form id="form_data" name="form_data" method="post" class="form-horizontal">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="pid" id="pid" value="">
				<input type="hidden" name="pic" id="pic" >
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="opmode" id="opmode" value="">
				<html:select id="dept_list" name="dept_list"  options="dept_list" style="display-none"/>
				<table class="table table-bordered" >
					<tr>
						<th>
						<nobr>
							员工编号*
						</nobr></th>
						<td>
						<input class="form-control" type="text" id="emp_no" name="emp_no" class="input-sm"  check="require" msg="请输入员工编号">
						</td>
						<th rowspan="4"> 照片
						<br>
						(120*160)</th>
						<td rowspan="3"><img width=120 height=160 id="emp_pic" ></td>
					</tr>
					<tr>
						<th>姓名*</th>
						<td>
						<input  class="form-control" type="text" id="emp_name" name="emp_name" class="input-sm" check="require" msg="请输入姓名">
						</td>
					</tr>
					<tr>
						<th>部门*</th>
						<td>
						<input name="dept_id" id="dept_id" type="hidden" msg="请选择部门" check="require" />
						<div class="input-group ">
							<input class="form-control" type="dept_name"  id="dept_name" type="text" msg="请选择部门" check="require"  />
							<div class="input-group-btn">
								<a class="btn btn-default" onclick="select_dept();" > <i class="icon-search" ></i> </a>
							</div>
						</div></td>
					</tr>
					<tr>
						<th>电子邮箱</th>
						<td>
						<input type="text" id="email" name="email" class="input-sm">
						</td>
						<td>
						<include file="Layout:uploader" />
						</td>
					</tr>
					<tr>
						<th>性别</th>
						<td>
						<select name="sex" id="sex" class="input-sm">
							<option  value="male">男</option>
							<option value="female">女</option>
						</select></td>
						<th>生日</th>
						<td>
						<input type="text" id="birthday" name="birthday" readonly="readonly" class="input-date">
						</td>
					</tr>
					<tr>
						<th>职级</th>
						<td>
						<html:select id="rank_id" name="rank_id" style="input-sm"  first="选择组" options="rank_list" />
						</td>
						<th>职位</th>
						<td>
						<html:select id="position_id" name="position_id" style="input-sm"  first="选择组" options="position_list"  />
						</td>
					</tr>
					<tr>
						<th>
						<nobr>
							负责业务
						</nobr></th>
						<td colspan="3">
						<input type="text" id="duty" name="duty" class="col-md-12">
						</td>
					</tr>
					<tr>
						<th>办公室电话</th>
						<td>
						<input type="text" id="office_tel" name="office_tel" class="input-date">
						</td>
						<th>移动电话</th>
						<td>
						<input type="text" id="mobile_tel" name="mobile_tel" class="input-date">
						</td>
					</tr>
					<tr>
						<th>状态</th>
						<td colspan="3">
						<select class="input-date"  name="is_del" id="is_del">
							<option  value="0">启用</option>
							<option value="1">禁用</option>
						</select></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
